package org.example.controller.shanjia;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.example.entity.Dingdan;
import org.example.result.Result;
import org.example.service.DingdanService;
import org.example.vo.DingdanVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/shanjia/dingdan")
@Slf4j
@Api(tags = "商家订单相关接口")
public class GidingdanController {

    @Autowired
    DingdanService dingdanService;


    /**
     * 发货修改
     * @param
     * @return
     */
    @PutMapping("/fhxg")
    @ApiOperation(value = "发货修改")
    public Result fhxg(@RequestParam( "id") int id){

        dingdanService.xg(id,2);
        return Result.success();
    }

    /**
     * 退还修改
     * @param
     * @return
     */
    @PutMapping("/thxg")
    @ApiOperation(value = "退还修改")
    public Result thxg(@RequestParam( "id") int id,@RequestParam( "tuih") String tuih){

        dingdanService.xgxz(id,6,tuih);
        return Result.success();
    }


    /**
     * 处理查询
     * @param username
     * @return
     */
    @GetMapping("/clcx")
    @ApiOperation(value = "处理查询")
    public Result<List<Dingdan>> clcx(@RequestParam( "username") String username){

        return Result.success(dingdanService.glcx(username,6));
    }

    /**
     * 发货查询
     * @param username
     * @return
     */
    @GetMapping("/shouhcx")
    @ApiOperation(value = "发货查询")
    public Result<List<Dingdan>> shouhcx(@RequestParam( "username") String username){

        return Result.success(dingdanService.glcx(username,1));
    }



    /**
     * 退款查询
     * @param username
     * @return
     */
    @GetMapping("/tkcx")
    @ApiOperation(value = "收货查询")
    public Result<List<Dingdan>> tkcx(@RequestParam( "username") String username){

        return Result.success(dingdanService.glcx(username,5));
    }

    /**
     * 退款修改
     * @param
     * @return
     */
    @PutMapping("/tkxg")
    @ApiOperation(value = "退款修改")
    public Result tkxg(@RequestParam( "id") int id){

        dingdanService.xg(id,6);
        return Result.success();
    }

    /**
     * 退款修改
     * @param
     * @return
     */
    @PutMapping("/tkcl")
    @ApiOperation(value = "退款处理")
    public Result tkcl(@RequestParam( "id") int id){

        dingdanService.xgxz(id,6,"-1");
        return Result.success();
    }
    /**
     * 处理删除
     * @param
     * @return
     */
    @DeleteMapping("/clsc")
    @ApiOperation(value = "处理删除")
    public Result clsc(@RequestParam( "id") int id){
        dingdanService.clsc(id,1);
        return Result.success();
    }


    /**
     * 数据统计查询
     * @param username
     * @return
     */
    @GetMapping("/sjtjcx")
    @ApiOperation(value = "数据统计查询")
    public Result<List<DingdanVO>> sjtjcx(@RequestParam( "username") String username){

        return Result.success(dingdanService.sjtjcx(username));
    }

}
